home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / RES86A.ASM < prev    next >
Assembly Source File  |  1985-08-02  |  44KB  |  2,367 lines

  1.     title    'RES86 DISASSEMBLER'
  2.     page    60,132
  3. ;
  4. ;    last edit 02/10/85 wde
  5. ;    2/10/85 2.3b fix goof in read .ctl funct
  6. ;    fix flow indic semic test,repair 8080 sym lookup
  7. ;    fix sym type write bug
  8. ;    1/17 2.3a add fixes from b kendall
  9.  
  10. ;    3/21/85 3.0 convert to masm format for ms-dos systems by Craig Derouen
  11.  
  12.  
  13. code    segment byte public
  14.  
  15.     extrn    cntenb:byte,opdtyp:byte,quiflg:byte,segflg:byte,segmsk:byte
  16.     extrn    segsho:byte,sdflg:byte,trmflg:byte,typndx:byte,wfiflg:byte
  17.     extrn    wrtflg:byte,xcsw:byte,adb:byte,strcnt:byte,symtyp:byte
  18.  
  19.     extrn    ascbld:word,cofset:word,ctlbas:word,ctltop:word,curofs:word
  20.     extrn    curpar:word,dmpcnt:word,dmpend:word,dmpstt:word,docend:word
  21.     extrn    doctbl:word,ecnt:word,fndadd:word,fndpc:word,hiload:word
  22.     extrn    insloc:word,lastwd:word,liscnt:word,mcbsiz:word,ofsptr:word
  23.     extrn    nrsegs:word,nxtctl:word,pcntr:word,rplptr:word,segsiz:word
  24.     extrn    stack:word,symtp:word,xcptr:word,cmdbuf:word
  25.     extrn    segnam:word,mcbbas:word,fake_comtbl:word
  26.  
  27.     extrn    addfn:near,bdos:near,cmentr:near,cmkill:near
  28.     extrn    creatf:near,cstbl:near,crlf:near,dline:near
  29.     extrn    dcrlf:near,fclose:near,fopen:near,gtcmd:near,gtval:near
  30.     extrn    hexl:near,hexr:near,ifasci:near,initbl:near
  31.     extrn    keychk:near,lita86:near,litall:near,litcmd:near,litctl:near
  32.     extrn    litdoc:near,litsym:near,lngth:near,locsym:near,prntde:near
  33.     extrn    prtstr:near,prspc:near,prword:near,pstar:near,pstrg:near
  34.     extrn    rdfchr:near,semic:near,symbas:near,symluk:near
  35.     extrn    tabc:near,typech:near,wtfchr:near,xo:near,xo0:near,flushf:near
  36.     extrn    cmpstr:near,pstg:near
  37.  
  38.     public    start,hsym,nwln0,delim,cmerr,nxcmd
  39.  
  40.     public    fcb,tbuf
  41.  
  42. ; dummy publics for symbol file
  43.  
  44.     public    entry,ardnam,restrt,l01cf,funlp,fndfun,segonl,fcttbl,fctend
  45.     public    deliok,cmhelp,cmtrim,trmof,cmpurg,l02c9,cmprlg,l02df,pfnlp
  46.     public    nofnam,pnmdun,l031d,prlglp,l032c,l033d,l034b,l0362,l0380,l0394
  47.     public    nodisp,sgreqs,updseg,segmch,segmtb,cmqiet,l03b2,cmdump,l0411
  48.     public    l0418,dump0,dump1,dump3,dmphdr,cntdmp,dump4,dmpln,wdspc1
  49.     public    wdspc2,wdspc3,dmpasc,period,chrctr,wdspc4,lcmplt,sducnt,l04e8
  50.     public    l04ef,dusymt,frmbgn,frmsym,agnsym,l051a,spit,spit1,spitcr,spcrlf
  51.     public    spcry,iecnt,prntos,gfnam,l056a,l057d,nodriv,mvnfld
  52.     public    eatfld,l05b6,padfld,cmatmt,cmbld,cmlist,list1,list2,list3
  53.     public    tenl,contl,flagck,builda,loop8,follow,morel,nwln,ncsemi,cntcmt
  54.     public    ntbksl,morel1,morel2,ncmt,cml15,l06fd,ckbmd,ckhmd,ckwmd,badmd,ictl
  55.     public    slicnt,l0762,l0776,l077d,dsmode,wmode,stpln,hmode,bmode,bmode1
  56.     public    nprtc,morinv,ltlf,mvup,trysym,nstpln,l0864,nxinv,conasc,morasc
  57.     public    l08ac,yet,still,lastqt,fnlqt,qtb,cmstts,nodoct,l0984,sgplp
  58.     public    usdseg,sgpen,prwval,cmfind,l09c6,l09d1,prevf,nyet
  59.     public    cmeof,l0a35,cmread,rdaprv,wntall,lodall,chgtyp,ntlall,symffd
  60.     public    l0a8a,wntcmd,lodcmd,cmdlds,modofs,cmhlp,cmhmlp,set_dmablk
  61.     public    mrqok,l0ac4,l0adc,l0aec,doclod,gotdoc,lodsym,comrd_lp
  62.     public    ldsym2,loddoc,lddoc2,ldasfl,skppre,l0b6c,drdsk1,lpasld,ldassp
  63.     public    hexbin,l0ba3,l0ba8,l0baf,l0bb5,erstbl,etlp1,etlp2,cmsave
  64.     public    savok,allsav,nosdoc,nossym,havctl,ntsall,ntssym,ntsctl,symsav
  65.     public    l0bf4,l0bf7,sdskp1,l0c0c,oufend,ntsdoc,outadr,sava86,savdoc
  66.     public    rrqerr,l0d20,cmctl,l0d45,l0d4f,l0d5a,enterc,entrc2,entrc4
  67.     public    l0d84,l0dba,l0dc6,cltrck,ctlck2,cltrrt,l0bf5,entrc5,entrc7
  68.     public    entrc8,l0e34,ctlook,ctlk2,l0e4s,l0e5c,l0e48,ctlk4,l0e65,clist0
  69.     public    clist,clist2,l0e87,l0e99,skclis,savctl,svctl0,l0ebf,l0ee6
  70.     public    lodctl,ctlfnd,l0ef7,l0efd,l0f0b,l0f23,l0f30,cmcmnt,cmnt0,cmnt2
  71.     public    cmnt1,l0f52,l0f5d,l0f71,l0f7d,comchk,l0fa6,l0fb2,l0fc3,l0fce
  72.     public    l0fd4,l0fd8,l0fec,l0ffa,l100b,l1015,l1023,l1041,l104c,cmusec
  73.     public    l10ce,ustok,uaset,l10ef,l111c,l1151,l1152,good_vers,good_mem
  74.  
  75.     assume cs:code,ds:code
  76.  
  77.     org    5ch
  78. fcb    db    36 dup (?)
  79. tbuf    db    128 dup(?)    ;that takes care of the first page
  80.  
  81.  
  82. symmax    equ    9        ;max chars in symbol
  83. tab    equ    9
  84. cr    equ    0dh
  85. lf    equ    0ah
  86. initlcnt equ    20
  87.  
  88. ;
  89.     org    100h
  90.  
  91.     if2
  92.     %out    Compiling in PASS 2 finally!
  93.     endif
  94.  
  95. start:
  96.     mov    ah,30h
  97.     int    21h
  98.     cmp    al,2
  99.     jae    good_vers
  100.     mov    dx,offset bad_vers
  101.     mov    ah,9
  102.     int    21h
  103.     int    20h            ; back to DOS!
  104.  
  105. bad_vers db    cr,lf,7,'Wrong version of DOS! Must be 2.0 or higher$'
  106.  
  107. good_vers:
  108. ; First thing is to de-allocate memory so we can grab portions at a time.
  109.     mov    bx,offset symbas    ; the end of program
  110.     sub    bx,100h            ; start of program
  111.     mov    cl,4
  112.     shr    bx,cl            ; convert to paras!
  113.  
  114. ; Now add about 10k for symbol table
  115.     add    bx,640            ; 10K in paras
  116.     mov    ah,4ah
  117. ;    int    21h            ; here we go!
  118. ;    jnc    good_mem        ; we have enough!
  119. ;    mov    ah,9
  120. ;    mov    dx,offset memory_fail
  121. ;    int    21h
  122. ;    mov    ax,4cffh
  123. ;    int    21h            ; exit with a -1
  124. ;
  125. ;memory_fail db    cr,lf,7,'Not enough memory to run!$'
  126.  
  127. good_mem:
  128.  
  129.     call    entry
  130.     db    'RESOURCE by Ward Christensen',cr,lf
  131.     db    'Transl. to 8086 by Larry Etienne',cr,lf
  132.     db    'Converted 8086 MS-DOS Ver. 3.0',cr,lf
  133.     db    'by C.Derouen (3-26-85)',cr,lf
  134.     db    'Copyright 1980$'
  135. ;
  136. entry:    pop    dx
  137.     mov    ax,ds
  138.     cli
  139.     mov    ss,ax
  140.     mov    sp,offset stack
  141.     sti
  142.     mov    es,ax            ;start = data seg
  143.     push    cs
  144.     pop    ds            ;segment for signon msg
  145.     mov    ah,9
  146.     call    bdos
  147.     mov    ax,ss
  148.     mov    ds,ax            ;restore normal
  149.     call    initbl
  150.     mov    al,fcb+1
  151.     cmp    al,' '+1
  152.     jb    restrt
  153.     call    prtstr
  154.     db    cr,lf,'Reading All Files for ',0
  155.     mov    bx,offset fcb+1
  156.     mov    ch,8
  157. ardnam:    mov    al,[bx]
  158.     call    typech
  159.     inc    bx
  160.     dec    ch
  161.     jnz    ardnam
  162.     call    lodall
  163.     call    prtstr
  164.     db    cr,lf,'Read Complete',cr,lf,0
  165.     jmp    short fstcmd
  166. ;
  167. restrt:    call    initbl
  168. fstcmd:    call    prtstr
  169.     db    cr,lf,'Type H for Help, ? for Stats',cr,lf,0
  170. ;
  171. nxcmd:    xor    al,al
  172.     mov    wfiflg,al
  173.     mov    quiflg,al        ;not quiet, no output
  174.     mov    segflg,al        ;clear segment use
  175.     mov    sp,offset stack
  176.     call    gtcmd
  177. l01cf:    mov    bx,offset cmdbuf+2    ;first chars of command
  178.     cmp    word ptr 1[bx],':S'
  179.     jz    segonl            ;just change segment
  180.     mov    al,[bx]            ;get the char
  181.     mov    bx,offset fcttbl
  182.     mov    ch,(offset fctend-offset fcttbl)/3    ;tbl entries
  183. funlp:    cmp    al,cs:[bx]        ;test char match
  184.     jz    fndfun
  185.     inc    bx
  186.     inc    bx
  187.     inc    bx
  188.     dec    ch
  189.     jnz    funlp
  190.     jmp    cmerr
  191. ;
  192. fndfun:    inc    bx
  193.     mov    dx,cs:[bx]        ;address of function
  194.     jmp    dx
  195. ;
  196. segonl:    inc    bx    ;pre-adj
  197.     call    updseg
  198.     jmp    short nxcmd
  199. ;
  200. fcttbl    db    cr
  201.     dw    offset nxcmd
  202.     db    ';'
  203.     dw    offset cmcmnt
  204.     db    'A'
  205.     dw    offset cmatmt
  206.     db    'B'
  207.     dw    offset cmbld
  208.     db    'C'
  209.     dw    offset cmctl
  210.     db    'D'
  211.     dw    offset cmdump
  212.     db    'E'
  213.     dw    offset cmentr
  214.     db    'F'
  215.     dw    offset cmfind
  216.     db    'G'
  217.     dw    offset cmexit
  218.     db    'H'
  219.     dw    offset cmhelp
  220.     db    'K'
  221.     dw    offset cmkill
  222.     db    'L'
  223.     dw    offset cmlist
  224. ;    db    'O'
  225. ;    dw    offset cmofst
  226.     db    'P'
  227.     dw    offset cmprlg
  228.     db    'Q'
  229.     dw    offset cmqiet
  230.     db    'R'
  231.     dw    offset cmread
  232.     db    'S'
  233.     dw    offset cmsave
  234.     db    'T'
  235.     dw    offset cmtrim
  236.     db    'U'
  237.     dw    offset cmusec
  238.     db    'X'
  239.     dw    offset cmpurg
  240.     db    'Z'
  241.     dw    offset cmeof
  242.     db    '?'
  243.     dw    offset cmstts
  244. fctend    db    0
  245. ;
  246. cmerr:    xor    al,al
  247.     mov    wfiflg,al
  248.     mov    quiflg,al        ;clear output and silent flags
  249.     pop    bx            ;addr called from
  250.     push    bx            ;in case stack empty 
  251.     call    prword            ;show where for debugging
  252.     call    prtstr
  253.     db    '? Cmd. Error',7,cr,lf,0
  254.     jmp    nxcmd
  255. ;
  256. delim:    cmp    al,' '
  257.     jz    deliok
  258.     cmp    al,','
  259.     jz    deliok
  260.     call    cmerr    ;expected delimiter missing
  261. deliok:    ret
  262.  
  263. ; Exit resource here
  264. cmexit:
  265.     mov    ax,4c00h    ; say no errors
  266.     int    21h
  267.  
  268. ;
  269. ;    help function
  270. ;
  271. cmhelp:    
  272. ; Test to see if extended help is needed.
  273.     mov    al,byte ptr cmdbuf+3
  274.     cmp    al,cr        ; nothing there?
  275.     je    full_help
  276.     cmp    al,'X'        ; help extended key
  277.     jne    full_help
  278.     jmp    extnd_help    ; show extended help
  279. full_help:
  280.     call    prtstr            ;lots to put out here!
  281. ;line  1
  282.     db    cr,lf,'             HELP ON RES86 -- COMMAND SUMMARY'
  283. ;line  2
  284.     db    cr,lf,';ADDR,@COMMENT    ENTER COMMENT AT ADDR    '
  285.     db    ' @={;|*|\|} \=NL, ;=APPND, *=REPL INST'
  286. ;line  3
  287.     db    cr,lf,';        LIST COMMENTS TABLE    '
  288.     db    ';ADDR,        DELETE COMMENT'
  289. ;line  4
  290.     db    cr,lf,"A (SEE L)    ATTEMPT TO FIND DB'",'S    '
  291.     db    'B (SEE L)    BUILD SYMBOL TABLE'
  292. ;line  5
  293.     db    cr,lf,'C        DUMP CONTROL TABLE    '
  294.     db    'CNNNN        DUMP CTRL TABLE AT NNNN'
  295. ;line  6
  296.     db    cr,lf,'CNNNN,X         SET CTRL (X=BEHISW)    '
  297.     db    'DNNNN        DUMP FROM NNNN ON'
  298. ;line  7
  299.     db    cr,lf,'DAAAA,BBBB    DUMP OVER RANGE        '
  300.     db    'D,BBBB        DUMP THRU BBBB'
  301. ;line  8
  302.     db    cr,lf,'D        DUMP A PAGE MORE    '
  303.     db    'D=NN        SET DUMP SIZE DEFAULT'
  304. ;line  9
  305.     db